package com.sensePlusVR.base;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.sensePlusVR.utils.MyLog;

/**
 * 
 * @author: Loren
 * @create: 2016-8-10下午2:55:43
 * @desc: Fragment 基类
 * 
 */
public class BaseFragment extends Fragment {
	//private static final String TAG_BASE = BaseFragment.class.getSimpleName();
	 //private String TAG_ACTIVITY = TAG +  "-->";
    private String TAG = getClass().getSimpleName();//当前的子Fragment
	protected boolean isVisible;
	 

	 @Override
	public void onAttach(Context context) {
		// TODO Auto-generated method stub
		super.onAttach(context);
		MyLog.d(TAG, "onAttach");
	}
	 
	 @Override
	public void onCreate(@Nullable Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		MyLog.d(TAG, "onCreate");
	}
	 
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		MyLog.d(TAG, "onCreateView");
		return super.onCreateView(inflater, container, savedInstanceState);
	}

	
	@Override
	public void onActivityCreated(@Nullable Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		MyLog.d(TAG, "onActivityCreated");
	}
	
	
	@Override
	public void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		MyLog.d(TAG, "onStart");
	}
	
	@Override
	public void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		MyLog.d(TAG, "onResume");
	}
	
	@Override
	public void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
		MyLog.d(TAG, "onPause");
	}
	
	@Override
	public void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
		MyLog.d(TAG, "onStop");
	}
	
	
	@Override
	public void onDestroyView() {
		// TODO Auto-generated method stub
		super.onDestroyView();
		MyLog.d(TAG, "onDestroyView");
	}
	
	@Override
	public void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		MyLog.d(TAG, "onDestroy");
	}
	
	@Override
	public void onDetach() {
		// TODO Auto-generated method stub
		super.onDetach();
		MyLog.d(TAG, "onDetach");
	}
	
	@Override
	public void onHiddenChanged(boolean hidden) {
		// TODO Auto-generated method stub
		super.onHiddenChanged(hidden);
		MyLog.d(TAG, "hidden : " + hidden);
	}
	
	
	/**
	 * 在这里实现Fragment数据的缓加载.
	 */
	@Override
	public void setUserVisibleHint(boolean isVisibleToUser) {
		super.setUserVisibleHint(isVisibleToUser);
		if (getUserVisibleHint()) {
			isVisible = true;
			onVisible();
		} else {
			isVisible = false;
			onInvisible();
		}
	}

	protected void onVisible(){}

	protected void onInvisible(){}
}
